package com.ler.yrmall.order.enums;

import com.ler.yrmall.exception.BusinessException;

/**
 * @author Leron
 * @version 1.0
 */
public enum PaymentEnum {

    /**
     * 支付方式
     */
    ZFB(1,"支付宝",Object.class),

    WX(2,"微信支付",Object.class);

    private final Integer code;

    private final String dict;

    /**
     * 处理交易的实现类
     */
    private final Class<?> processClass;

    PaymentEnum(Integer code, String dict, Class<?> processClass) {
        this.code = code;
        this.dict = dict;
        this.processClass = processClass;
    }

    public static PaymentEnum getByCode(Integer code) {
        for (PaymentEnum value : PaymentEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new BusinessException("不存在的支付方式代码");
    }

    public Integer getCode() {
        return code;
    }

    public String getDict() {
        return dict;
    }

    public Class<?> getProcessClass() {
        return processClass;
    }

}
